package model_layer;


/**
 * The Class SaleLineItem.
 */
public class SaleLineItem
{
	
	private float price;
	private Product product;
	private int amount;
	boolean can_go_below_quantity;

	/**
	 * Instantiates a new sale line item.
	 */
	public SaleLineItem()
	{
		can_go_below_quantity = false;
	}

	/**
	 * Instantiates a new sale line item.
	 *
	 * @param product the product
	 * @param amount the amount
	 */
	public SaleLineItem(Product product, int amount)
	{
		this.product = product;
		this.amount = amount;
		can_go_below_quantity = false;
		calculate_price();
	}

	/**
	 * Gets the product.
	 *
	 * @return the product
	 */
	public Product getProduct()
	{
		return product;
	}

	/**
	 * Gets the amount.
	 *
	 * @return the amount
	 */
	public int getAmount()
	{
		return amount;
	}

	/**
	 * Sets the product.
	 *
	 * @param product the new product
	 */
	public void setProduct(Product product)
	{
		this.product = product;
	}

	/**
	 * Sets the amount.
	 *
	 * @param amount the new amount
	 */
	public void setAmount(int amount)
	{
		this.amount = amount;
	}

	/**
	 * Gets the price.
	 *
	 * @return the price
	 */
	public float getPrice()
	{
		return price;
	}

	/**
	 * Sets the price.
	 *
	 * @param price the new price
	 */
	public void setPrice(float price)
	{
		this.price = price;
	}
	
	/**
	 * Calculates the price.
	 */
	public void calculate_price()
	{
		price = getProduct().getPrice() * getAmount();
	}

	/**
	 * Returns if it can go below minimum quantity.
	 *
	 * @return true, if successful
	 */
	public boolean can_go_below_quantity()
	{
		return can_go_below_quantity;
	}

	/**
	 * Sets if it can go below minimum quantity.
	 *
	 * @param boolean value with the given statement
	 */
	public void set_can_go_below_quantity(boolean can_go_below_quantity)
	{
		this.can_go_below_quantity = can_go_below_quantity;
	}
}
